	
	/*******************互助信息************************************/
	var helpInfoMax=4;		//最多展示的互助信息
	function helpInfomation(){			//互助信息
		getHelpInfomation();		//访问API	
	}
	function getHelpInfomation(){	//访问API
		request("GET", "/getHelpInfomation", {}, getHelpInfomationSuccess, getHelpInfomationError, true);
		function getHelpInfomationSuccess(responseData){
			if(responseData.code=="1400")		//获取成功
			{
				$('#AllHelpInfo').empty();		//清空
				var items=responseData.data;
				for(var i=0;i<items.length;i++){	
					
					var info=$("<div>");
					info.attr('id',items[i].mutual_help_id);
					
					var span_views=$("<span>").text(items[i].number_of_views).attr('id','number_of_views');
	
					var span_title=$("<span>").text(items[i].title).attr('id','title');
					var span_helper_id=$("<span>").text('帮助者:'+items[i].helper_id).attr('id','helper_id');
					var span_seek_id=$("<span>").text('受助者:'+items[i].seek_id).attr('id','seek_id');
					var span_date=$("<span>").text('帮助日期:'+items[i].help_date).attr('id','help_date');
					
					var span_post_id=$("<span>").text('帖子:'+items[i].post_id).attr('id','post_id');
					span_post_id.click(function(){
						var post_id=$(this).text().split(':')[1];
						showPost(post_id,0);		//显示帖子
					})
					var span_content=$("<span>").text(items[i].content).attr('id','content');
	
					info.addClass('oneHelpInfo');
					info.append(span_views);
					info.append(span_title);
					info.append(span_helper_id);
					info.append(span_seek_id);
					info.append(span_date);
					info.append(span_post_id);
					info.append(span_content);
					
					$('#AllHelpInfo').append(info);
					
					if(i<helpInfoMax){		//首页显示
						var img=$('<img>');
						img.attr("src","static/img/collection0.png");
						var li2=$('<li>');
						li2.text(items[i].content).attr("id",items[i].mutual_help_id);
						li2.click(function(){					
							showOneHelpInfo($(this).attr('id'));	//只显示点击中的互助信息
						})
						var li1=$('<li>');
						li1.append(img);
						$("#lookList").append(li1);
						$("#informationList").append(li2);
					}
					
				}	
			}
			else
			{
				alert(responseData.description);	
			}
		};
		function getHelpInfomationError(){}
	}
	/*******************互助信息************************************/
	
	
	function showMoreHelpInfo(){	//展示更多的互助信息
		ChangeTo($('#more'));
		$('#AllHelpInfo').show().siblings().hide();	//互助信息展示
		$("h1").text("互助信息");
		$('#AllHelpInfo').children().show();
	}
	function showOneHelpInfo(mutual_help_id){	//只显示一条互助信息
		ChangeTo($('#more'));
		$('#AllHelpInfo').children().hide();
		$('#AllHelpInfo').find('#'+mutual_help_id).show();
		$('#AllHelpInfo').show().siblings().hide();
		$("h1").text("互助信息");
	}
	
	function showPost(post_id,ret){		//显示帖子
		request("GET", "/getOnePost/"+post_id, {}, getOnePostSuccess, getOnePostError, true);
		function getOnePostSuccess(responseData){
			if(responseData.code=="2000")
			{
				var post=responseData.data;
				$('#AllHelpInfo').hide();	//互助信息展示
				$('#onePost #theme').val(post.theme);
				$('#onePost #postId').val(post.post_id);
				$('#onePost #publishDate').val(post.publish_date);
				$('#onePost #effectiveDate').val(post.effective_date);
				$('#onePost #numberOfViews').val(post.number_of_views);
				$('#onePost #content').val(post.content);
				$('#onePost #publisher').unbind().click(function(){	//查看个人信息
					getIndividualInfo(post_id,post.publisher_id);	//展示个人信息
				});
				
				$('#onePost').show().siblings().hide();	//互助信息展示
				$("h1").text("帖    子");
				if(ret==0){			//互助信息看帖子
					$('#onePost .bigBtn').hide();
					$('#onePost #prevBtn').unbind().click(function(){
						$('#AllHelpInfo').show().siblings().hide();
					})
				}	
				else if(ret==1){	//所有帖子看帖子
					$('#onePost .bigBtn').show();
					$('#onePost .YNBtn').hide();
					$('#onePost #prevBtn').unbind().click(function(){
						$('#AllPost').show().siblings().hide();
					})
					$('#onePost #submitBtn').unbind().click(function(){
						doMakeHelp(post.publisher_id,post.post_id);		//实行帮助/接受帮助
					})	
				}
				else if(ret==2)		//审核看帖子
				{	
					$("h1").text("审核帖子");
					$('#onePost .bigBtn').hide();
					$('#onePost .YNBtn').show();
					$('#onePost #submitNBtn').unbind().click(function(){
						
						doVerifyPost(post_id,'N');		//审核不通过
					});
					$('#onePost #submitYBtn').unbind().click(function(){
						doVerifyPost(post_id,'Y');		//审核通过
					});
					
					$('#onePost #prevBtn').unbind().click(function(){
						$("#reviewPost").click();
					})
				}	
			}
			else
				alert(responseData.description);
		}
		function getOnePostError(){}
	}
	
	function allNotice(){	//获取所有公告
		getAllNotice();		
	}
	function getAllNotice(){	//访问API
		request("GET", "/getAllNotice", {}, getAllNoticeSuccess, getAllNoticeError, true);
		function getAllNoticeSuccess(responseData){
			if(responseData.code=="2100")
			{
				var notices=responseData.data;
				var txt='';
				$('#AllNotice').empty();
				for(var i=0;i<notices.length;i++){
					var span_title=$('<span>').text("公   告 "+String(i+1)).attr('id','title');
					var span_content=$('<span>').text(notices[i].content).attr('id','content');
					var span_date=$('<span>').text(notices[i].publish_date).attr('id','publish_date');
					var div=$('<div>').append(span_title,span_content,$('<br>'),span_date).addClass('oneNotice');
					$('#AllNotice').append(div);
					txt+="公   告 "+String(i+1)+": "+notices[i].content+"     ";
				}
				//替换文本再添加样式，从而实现滚动效果
				$('#notice').find('.txt').text(txt);
				$('#notice').find('.txt-clone').text(txt);
//				$('#notice').find('#txt').addClass('txt');
//				$('#notice').find('#scroll').addClass('scrollbox');
//				$('#notice').addClass('txt-scroll');
			}
			else
				alert(responseData.description);
		}
		function getAllNoticeError(){}
	}
	

	function getIndividualInfo(post_id,publisher_id){		//展示个人信息
		
		request("GET", "/getIndividualInfo/"+publisher_id, null, getIndividualInfoSuccess,getIndividualInfoError, true);	
		function getIndividualInfoSuccess(responseData){
			if(responseData.code=="2500")		//修改成功
			{
				var userInfo=responseData.data;
				$("h1").text("个人详情");
				$("#individualInfo #nick_name").text(userInfo.nick_name);
				$("#individualInfo #user_id").text(userInfo.user_id);
				$("#individualInfo #real_name").text(userInfo.real_name);
				$("#individualInfo #date_of_birth").text(userInfo.date_of_birth);
				$("#individualInfo #sign_up_date").text(userInfo.sign_up_date);
				$("#individualInfo #sex").text(userInfo.sex);
				$("#individualInfo #points").text(userInfo.points);
				$("#individualInfo #telephone").text(userInfo.telephone);
				$("#individualInfo #email").text(userInfo.email);
				$("#individualInfo #address").text(userInfo.address);
				$("#individualInfo #prevBtn").unbind().click(function(){
					$('#onePost').show().siblings().hide();	//互助信息展示
					$("h1").text("帖    子");
				})
				$('#individualInfo').show().siblings().hide();	//修改展示栏
			}
			else
			{
				alert(responseData.description);	
			}		
		}
		function getIndividualInfoError(){}
	}
	
	function doMakeHelp(seek_id,post_id){	//提供帮助/接受帮助
		request("POST", "/doMakeHelp", {'seek_id':seek_id,'post_id':post_id}, doMakeHelpSuccess,doMakeHelpError, true);	
		function doMakeHelpSuccess(responseData){
			if(responseData.code=="2600"){
				alert(responseData.description);
				showMorePost();		//显示更多的帖子
			}
			else
			{
				alert(responseData.description);	
			}
		}
		function doMakeHelpError(){}
	}	
	

